cmake_minimum_required(VERSION 3.22.1)
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_C_COMPILER /usr/local/arm/5.4.0/usr/bin/arm-linux-gcc)

# 静态链接设置
set(CMAKE_EXE_LINKER_FLAGS "-static -L/usr/local/arm/5.4.0/usr/lib -Wl,--start-group -Wl,--end-group")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set(BUILD_SHARED_LIBS OFF)

# 显式设置库搜索路径
link_directories(/usr/local/arm/5.4.0/usr/lib)

# OpenSSL 手动配置
set(OPENSSL_ROOT_DIR "/usr/local/arm/5.4.0/usr")
set(OPENSSL_INCLUDE_DIR "${OPENSSL_ROOT_DIR}/include")
set(OPENSSL_SSL_LIBRARY "${OPENSSL_ROOT_DIR}/lib/libssl.a")
set(OPENSSL_CRYPTO_LIBRARY "${OPENSSL_ROOT_DIR}/lib/libcrypto.a")

# zlib 手动配置 - 使用绝对路径
set(ZLIB_ROOT "/usr/local/arm/5.4.0/usr")
set(ZLIB_INCLUDE_DIR "${ZLIB_ROOT}/include")
set(ZLIB_LIBRARY_FILE "${ZLIB_ROOT}/lib/libz.a")  # 更改变量名以强调是文件路径

project(instrument_project)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)

set(CURL_LIBRARY "/usr/local/arm/5.4.0/usr/lib/libcurl.a")

include_directories(.)
include_directories(./lvgl)
include_directories(./lvgl/src) 
include_directories(./lv_drivers)
include_directories(./ui)
include_directories(/usr/local/arm/5.4.0/usr/include)
include_directories(/usr/local/arm/5.4.0/usr/include/curl)
include_directories(${OPENSSL_INCLUDE_DIR})
include_directories(${ZLIB_INCLUDE_DIR})

add_subdirectory(lvgl)
add_subdirectory(lv_drivers)
add_subdirectory(ui)

add_executable(${PROJECT_NAME} main.c animation.c control.c gear.c indicators.c tires.c mode.c  data_manager.c  ui_message.c  ui_message_handler.c http_v1.c cJSON.c)
target_compile_options(${PROJECT_NAME} PRIVATE -g) 
target_link_libraries(${PROJECT_NAME} PRIVATE ${CURL_LIBRARY} ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY} ${ZLIB_LIBRARY_FILE}  lvgl  lvgl_drivers  lvgl::demos  lvgl::examples  ui pthread m dl)